﻿namespace Authentication.Data
{
    using Authentication.Configuration;
    using Authentication.Data.DBConfig;
    using Authentication.Model.Model;
    using System.Linq;
    using System.Data.Entity;
    public class AuthenticationEntities : DbContext
    {
        public AuthenticationEntities() : base(SystemConfiguration.ConnectionString) { }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Configurations.Add(new ApplicationConfiguration());//Application
            modelBuilder.Configurations.Add(new DictionaryConfiguration());//Dictionary
            modelBuilder.Configurations.Add(new AccountConfiguration());//Account
            modelBuilder.Configurations.Add(new AccountInfoConfiguration());//AccountInfo
            modelBuilder.Configurations.Add(new AccountRuleConfiguration());//AccountRule
            modelBuilder.Configurations.Add(new GroupConfiguration());//Account
            modelBuilder.Configurations.Add(new GroupRuleConfiguration());//AccountRule
            //modelBuilder.Configurations.Add(new LogConfiguration());//
            modelBuilder.Configurations.Add(new ObjectConfiguration());//Object
            modelBuilder.Configurations.Add(new ObjectSubstitutionConfiguration());//ObjectSubstitution
            modelBuilder.Configurations.Add(new PasswordAuditConfiguration());//PasswordAudit
            modelBuilder.Configurations.Add(new RuleConfiguration());//Rule
            modelBuilder.Configurations.Add(new AccountLogonAuditConfiguration());//AccountLogonAudit
        }

        public DbSet<Application> Applications { get; set; }
        public DbSet<Dictionary> Dictionaries { get; set; }
        public DbSet<Account> Accounts { get; set; }
        public DbSet<AccountInfo> AccountInfos { get; set; }
        public DbSet<ApplicationAccountRule> AccountRules { get; set; }
        public DbSet<ApplicationGroup> Groups { get; set; }
        public DbSet<ApplicationGroupRule> GroupRules { get; set; }
        public DbSet<ApplicationObject> Objects { get; set; }
        public DbSet<ObjectSubstitution> ObjectSubstitutions { get; set; }
        public DbSet<AccountPasswordAudit> PasswordAudits { get; set; }
        public DbSet<ApplicationRule> Rules { get; set; }
        public DbSet<AccountLogonAudit> AccountLogonAudits { get; set; }
    }
}
